package org.springframework.boot.netty.argumentResolver;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.HttpResponse;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.boot.autoconfigure.netty.enums.StartUpMode;
import org.springframework.boot.netty.listener.Message;

import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;

/**
 * Author: huoxingzhi
 * Date: 2021/1/14
 * Email: hxz_798561819@163.com
 */
public class RuntimeThrowableResolver extends ThrowableResolverAdapter {

    @Override
    public boolean supportsThrowable(Exception e) {
        Throwable cause = e.getCause();
        return cause instanceof RuntimeException;

    }

    @Override
    public void resolveException(Message message, Exception e)  {

        if(e.getCause() instanceof RuntimeException){
            RuntimeException runtimeException = (RuntimeException) e.getCause();
            throw runtimeException;
        }

    }


}
